﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>
  
  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/ecommerce">课程管理</a></li>
          <li class="active">排课管理</li>
          <li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title="团课详情"></i>&nbsp;&nbsp;<span>线上课程&nbsp;-&nbsp;团课详情</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper" style="margin-top:20px;">
            <div class="x-breadcrumb yellow clearfix">
              <h2>
                <span>学员信息</span>
              </h2>
              <c:set var="groups" value = "${persist.courseRoundGroup(roundCode)}"/>
              
              <c:if test="${not currentPrincipal.coursewareManager and not currentPrincipal.coursewareMonitor}">
                <c:if test="${not empty groups}">
                  <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/export" class="pull-right" style="margin-right: 10px; margin-top: 10px;" title="导出">导出学员</a>
                </c:if>
                <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/zip" data-target="#online-round-zip" data-toggle="modal" class="pull-right" style="margin-right: 10px; margin-top: 10px;" title="导出">生成zip</a>
                <c:if test="${not empty courseRoundResource}">
                  <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/zip-export" class="pull-right" style="margin-right: 10px; margin-top: 10px;" title="导出">下载ZIP</a>
                </c:if>
                <c:if test="${empty groups and persist.finishedInvestigateAmount(courseRounds[0].code == null ? roundCode : courseRounds[0].code) > 1}">
                  <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/group" data-target="#online-round-group" data-toggle="modal" class="pull-right" style="margin-right: 10px; margin-top: 10px;" title="分组">分组</a>
                </c:if>
              </c:if>
              
              <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/rounds/search?${empty queryString ? '' : queryString}" data-target="#online-round-search" data-toggle="modal" class="pull-right" style="margin-right: 10px; margin-top: 10px;" title="过滤查询">过滤查询</a>
              
            </div>
            
            <div class="x-breadcrumb-wrapper clearfix" style="position: relative; margin-top: 15px;">
              <c:choose>
                <c:when test="${empty groups}">
                  <div class="btn-group pull-left">
                    <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}?grouped=${param.grouped}"  class="btn btn-success x-btn btn-shadow btn-shadow-success ">
                      &nbsp;&nbsp;全部
                    </a>
                  </div>
                </c:when>
                <c:otherwise>
                  <div class="btn-group pull-left">
                   <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}?grouped=true"  class="btn btn-${empty param.group ? 'success' : 'default'} x-btn btn-shadow btn-shadow-${empty param.group ? 'success' : 'default'} ">
                      &nbsp;&nbsp;未分组
                    </a>
                  </div>
                  <c:forEach var="courseRoundGroup" items="${groups}">
                    <div class="btn-group pull-left">
                      <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}?grouped=true&group=${courseRoundGroup.name}"  class="btn btn-${param.group eq courseRoundGroup.name ? 'success' : 'default'} x-btn btn-shadow btn-shadow-${param.group eq courseRoundGroup.name ? 'success' : 'default'} ">
                        &nbsp;&nbsp;${courseRoundGroup.name}
                      </a>
                    </div>
                  </c:forEach>
                </c:otherwise>
              </c:choose>
              
              <c:if test="${not currentPrincipal.coursewareMonitor}">
                <div class="btn-group pull-right">
                  <%-- <c:if test="${persist.couldBatchChangeGroup(courseRounds)}">
                    <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/batch-change-group?${empty queryString ? '' : queryString}" data-target="#" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default">课件分组</a>
                  </c:if> --%>
                  <c:if test="${persist.couldBatchLink(courseRounds)}">
                    <a href="${ctx.host}/online-rounds/${courseRounds[0].code == null ? roundCode : courseRounds[0].code}/batch-link?${empty queryString ? '' : queryString}" data-target="#online-link" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default">生成课件链接</a>
                  </c:if>
                </div>
              </c:if>
            </div>
            
          </div>
          
          <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
            <thead>
              <tr>
                <th>编号</th>
                <th>学员名称</th>
                <th width="150px">产品名称</th>
                <th>课件属性</th>
                <th>联系方式</th>
                <th>调查问卷</th>
                <th>二维码</th>
                <th width="200px">用户备注</th>
                <th class="ellipsis" style="max-width: 200px;">备注</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="courseRound" items="${courseRounds}" varStatus="status">
                  <tr>
                    <td>${status.index + 1}</td>
                    <td>${courseRound.student.name}</td>
                    <td width="150px">${courseRound.product.name}</td>
                    <td><p>${courseRound.fitnessGroup.name}</p>
                        <p><c:if test="${not empty courseRound.student.tagIds}"><c:forEach var="tag" items="${persist.coursewareTags(courseRound.student.arrayTagIds)}">${tag.name}&nbsp;&nbsp;</c:forEach></c:if></p>
                    </td>
                    <td>${courseRound.student.mobile}</td>
                    <td>
                      <c:set var="investigation" value="${persist.orderInvestigationRecord(courseRound.order)}" />
                      <c:if test="${investigation.profile}">
                        <label class="label ${investigation.profileInvestigation ? 'label-success' : 'label-default'} label-outline" style="line-height:2.5;">个人信息</label>
                      </c:if>
                      <c:if test="${investigation.fit}">
                        &nbsp;&nbsp;<label class="label ${investigation.fitInvestigation ? 'label-success' : 'label-default'} label-outline" style="line-height:2.5;">身体信息</label>
                      </c:if>
                      <c:if test="${investigation.health}">
                        <br /><label class="label ${investigation.healthInvestigation ? 'label-success' : 'label-default'} label-outline" style="line-height:2.5;">健康信息</label>
                      </c:if>
                      <c:if test="${investigation.participate}">
                        &nbsp;&nbsp;<label class="label ${investigation.participateInvestigation ? 'label-success' : 'label-default'} label-outline" style="line-height:2.5;">参与信息</label>
                      </c:if>
                    </td>
                    <td>${courseRound.onlineRoundAttr.qrcodeStatus ? "<span class='text-success'>已上传<span>" : "<span class='text-danger'>未上传</span>"}<br /> ${investigation.qrcodeRemarks}</td>
                    <td width="200px">${investigation.userRemarks}</td>
                    <td  class="ellipsis" style="max-width: 200px;">${courseRound.attrs['course_remarks'].value}</td>
                    
                    <td>
                      <c:if test="${not currentPrincipal.coursewareMonitor}">
                        <c:if test="${not currentPrincipal.coursewareManager}">
                          <c:if test="${!investigation.qrcodeStatus and investigation.finish}">
                            <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/qrcode-upload?grouped=${param.grouped}" data-target="#online-round-qrcode-upload" data-toggle="modal" >上传二维码</a>&nbsp;&nbsp;
                          </c:if>
                        </c:if>
                        <c:if test="${empty courseRound.fitnessGroup}">
                          <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/change-group" data-target="#change-group" data-toggle="modal" >分组</a>&nbsp;&nbsp;
                        </c:if>
                        <c:if test="${persist.couldChangeGroup(courseRound.id)}">
                          <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/edit-group" data-target="#edit-group" data-toggle="modal" >修改分组</a>&nbsp;&nbsp;
                        </c:if>
                        <c:if test="${not empty courseRound.fitnessGroup}">
                          <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/edit-tag" data-target="#tag" data-toggle="modal" >修改标签</a>&nbsp;&nbsp;
                        </c:if>
                        <c:if test="${not currentPrincipal.coursewareManager}">
                          <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/remarks" data-target="#online-round-remarks" data-toggle="modal" >修改备注</a>
                          &nbsp;&nbsp;<a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/transfer-camp" data-target="#online-round-transfer-camp" data-toggle="modal" >转营</a>&nbsp;&nbsp;
                        </c:if>
                      </c:if>
                      <c:if test="${not empty groups and (currentPrincipal.root or currentPrincipal.admin or currentPrincipal.coursewareManager or currentPrincipal.onlineCoach)}">
                        <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}/transfer-class" data-target="#online-round-transfer-class" data-toggle="modal" >转班&nbsp;&nbsp;</a>
                      </c:if>
                      <a href="${ctx.host}/online-rounds/${courseRound.code}/rounds/${courseRound.id}">详情</a>
                    </td>
                    
                  </tr>
              </c:forEach>
            </tbody>
          </table>
          
          <c:choose>
            <c:when test="${refer eq 'view'}">
              <jsp:include page="/WEB-INF/include/page.jsp">
                <jsp:param name="url" value="online-rounds/${courseRounds[0].code}" />
                <jsp:param name="queryString" value="${queryString}" />
              </jsp:include>
            </c:when>
            <c:when test="${refer eq 'search'}">
              <jsp:include page="/WEB-INF/include/page.jsp">
                <jsp:param name="url" value="online-rounds/${courseRounds[0].code}/rounds" />
                <jsp:param name="queryString" value="${queryString}" />
              </jsp:include>
            </c:when>
          </c:choose>
          
        </div>
          
        </div>

      </div>

    </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/course/online-round-view.js">
    <script type="text/javascript">
      require(['page/course/online-round-view'], function(page) {
        page.init({
          status: '${status}',
          code: '${courseRounds[0].code}',
          grouped: '${param.grouped}'
        })
      })
    </script>
  </d:resource>
</body>

</html>
